package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.CountUserService;
import com.zr.service.impl.CountUserServiceImpl;

import net.sf.json.JSONObject;

/**
 * 处理CountUser请求
 * @author 
 *
 */
public class CountUserAction extends HttpServlet {
	private CountUserService countUserService = new CountUserServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		PrintWriter pw = resp.getWriter();
		JSONObject json = new JSONObject();
		int[] countUsers = countUserService.getCountUser();
		json.put("systemUser", countUsers[0]);
		json.put("knowledgeUser", countUsers[1]);
		json.put("user", countUsers[2]);
		pw.write(json.toString());
	}
}
